package sync

import (
	"promsync/progress/file"
	"promsync/progress/log"
	"strings"
)

type Sink struct {
	Fetch      *Fetcher
	ConfigFile string
}

func (sink *Sink) SinkConfig(data string) {

	if data == "" {
		log.Log.Errorf("空内容，不进行同步")
		return
	}

	builder := &strings.Builder{}
	builder.WriteString(data)
	s := builder.String()

	err := file.WriteAndCreateFullPath(sink.ConfigFile, s)
	if err != nil {
		log.Log.Errorf("写入配置内容失败: %s", err)
	}
}
